package utils;

import java.text.DecimalFormat;

import libutil.filewriter;

public class Damage_skill_data {

	protected Integer normal_max;
	protected Integer normal_min;
	protected Integer crit_max;
	protected Integer crit_min;
	protected Integer nb_normal;
	protected Integer nb_crit;
	protected Integer moyenne;
	protected Integer moyenne_normal;
	protected Integer moyenne_crit;
	protected Integer sum_crit;
	protected Integer sum_normal;
	protected Integer duration;
	
	public Damage_skill_data(){
		this.sum_crit = 0;
		this.sum_normal = 0;
		this.nb_normal = 0;
		this.nb_crit = 0;
		this.normal_min = 1000000000;
		this.normal_max = 0;
		this.crit_min = 1000000000;
		this.crit_max = 0;
	}

	public Integer getNormal_max() {
		return normal_max;
	}

	public void setNormal_max(Integer normal_max) {
		if(this.normal_max<normal_max){
			this.normal_max = normal_max;
		}
	}

	public Integer getNormal_min() {
		return normal_min;
	}

	public void setNormal_min(Integer normal_min) {
		if(normal_min<this.normal_min){
			this.normal_min = normal_min;
		}
	}

	public Integer getCrit_max() {
		return crit_max;
	}

	public void setCrit_max(Integer crit_max) {
		if(this.crit_max<crit_max){
			this.crit_max = crit_max;
		}
	}

	public Integer getCrit_min() {
		return crit_min;
	}

	public void setCrit_min(Integer crit_min) {
		if(crit_min<this.crit_min){
			this.crit_min = crit_min;
		}
	}

	public Integer getNb_normal() {
		return nb_normal;
	}

	public void incrmentNb_normal(Integer nb_normal) {
			this.nb_normal += nb_normal;
	}

	public Integer getNb_crit() {
		return nb_crit;
	}

	public void incrementNb_crit(Integer nb_crit) {
		this.nb_crit += nb_crit;
	}

	public Integer getMoyenne() {
		return moyenne;
	}

	public void calculateMoyenne() {
		if((this.nb_crit+this.nb_normal)>0){
			this.moyenne = (this.sum_crit+this.sum_normal)/(this.nb_crit+this.nb_normal);		
		}
	}

	public Integer getMoyenne_normal() {
		return moyenne_normal;
	}

	public void calculateMoyenne_normal() {
		if(this.nb_normal>0){
			this.moyenne_normal = this.sum_normal/this.nb_normal;
		}
	}

	public Integer getMoyenne_crit() {
		return moyenne_crit;
	}

	public void calculateMoyenne_crit() {
		if(this.nb_crit>0){
			this.moyenne_crit = this.sum_crit/this.nb_crit;
		}
	}

	public Integer getSum_crit() {
		return sum_crit;
	}

	public void incrementSum_crit(Integer sum_crit) {
		if(sum_crit!=null){
			this.sum_crit += sum_crit;
		}
	}

	public Integer getSum_normal() {
		return sum_normal;
	}

	public void incrementSum_normal(Integer sum_normal) {
		if(sum_normal!=null){
			this.sum_normal += sum_normal;
		}
	}
	public void print_numerical_informations(){
		System.out.println("****************************************");
		System.out.println("information numerique");
		System.out.println("somme hit normal : "+this.getSum_normal());
		System.out.println("somme hit critique : "+this.getSum_crit());
		System.out.println("nombre de hit : "+(this.getNb_crit()+this.getNb_normal()));
		System.out.println("nombre de hit normal : "+this.getNb_normal());
		System.out.println("nombre de hit critique : "+this.getNb_crit());
		System.out.println("plage de valeur normal : "+this.getNormal_min()+" - "+this.getNormal_max());
		System.out.println("plage de valeur critique : "+this.getCrit_min()+" - "+this.getCrit_max());
		System.out.println("Valeur de hit moyenne : "+this.getMoyenne());
		System.out.println("Valeur de hit moyen normal : "+this.getMoyenne_normal());
		System.out.println("Valeur de hit moyen critique : "+this.getMoyenne_crit());
		System.out.println("*****************************************");
	}
	public void print_numerical_informations_to_file(filewriter writer){
		writer.insereligne("****************************************");
		writer.insereligne("information numerique");
		writer.insereligne("somme hit normal : "+this.getSum_normal());
		writer.insereligne("somme hit critique : "+this.getSum_crit());
		writer.insereligne("nombre de hit : "+(this.getNb_crit()+this.getNb_normal()));
		writer.insereligne("nombre de hit normal : "+this.getNb_normal());
		writer.insereligne("nombre de hit critique : "+this.getNb_crit());
		writer.insereligne("plage de valeur normal : "+this.getNormal_min()+" - "+this.getNormal_max());
		writer.insereligne("plage de valeur critique : "+this.getCrit_min()+" - "+this.getCrit_max());
		writer.insereligne("Valeur de hit moyenne : "+this.getMoyenne());
		writer.insereligne("Valeur de hit moyen normal : "+this.getMoyenne_normal());
		writer.insereligne("Valeur de hit moyen critique : "+this.getMoyenne_crit());
		writer.insereligne("*****************************************");
	}
	
	public String[] print_numerical_informations_to_table(String skillname){
		DecimalFormat df = new DecimalFormat();
    	df.setMaximumFractionDigits(2);
		String[] result = new String[8];
		result[0] = skillname;
		result[1] = ""+(this.getSum_crit()+this.getSum_normal())/(this.duration/1000);
		result[2] = ""+(this.getSum_crit()+this.getSum_normal());
		result[3] = ""+(this.getNb_crit()+this.getNb_normal());
		if(this.getNb_crit()>0){
			double crit_ratio = ((double)this.getNb_crit()/((double)this.getNb_crit()+(double)this.getNb_normal()))*100;
			result[4] = ""+df.format(crit_ratio)+"%";
		}else{
			result[4] = "";
		}
		if(this.getNormal_min()<1000000000){
			result[5] = ""+this.getNormal_min()+" - "+this.getNormal_max();
		}else{
			result[5] = "0%";	
		}
		if(this.getCrit_min()<1000000000){
			result[6] = ""+this.getCrit_min()+" - "+this.getCrit_max();
		}else{
			result[6] = "";	
		}
		result[7] = ""+this.getMoyenne();
		return result;
	}

	public void setDuration(Integer duration) {
		this.duration = duration;
	}
}
